<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
import { usePublicHooks } from "../../../hooks";

const props = withDefaults(defineProps<FormProps>(), {
  id: String, // 添加 id prop
  formInline: () => ({
    id: "",
    push_base_url: "",
    secretkey: "",
    appid: "",
    status: 0
  })
});

const ruleFormRef = ref();
const { switchStyle } = usePublicHooks();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="推送url" prop="push_base_url">
      <el-input
        v-model="newFormInline.push_base_url"
        clearable
        placeholder="请输入推送url"
      />
    </el-form-item>
    <el-form-item label="secretkey" prop="secretkey">
      <el-input
        v-model="newFormInline.secretkey"
        clearable
        placeholder="请输入secretkey"
      />
    </el-form-item>
    <el-form-item label="appid" prop="appid">
      <el-input
        v-model="newFormInline.appid"
        clearable
        placeholder="请输入appid"
      />
    </el-form-item>
    <el-form-item label="状态">
      <el-switch
        v-model="newFormInline.status"
        inline-prompt
        :active-value="1"
        :inactive-value="0"
        active-text="启用"
        inactive-text="停用"
        :style="switchStyle"
      />
    </el-form-item>
  </el-form>
</template>
